package com.itheima.mapper;

import com.itheima.doman.pojo.Emp;
import com.itheima.doman.pojo.EmpQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {
    /*    //普通分页
        @Select("select count(*) from emp e left join dept d on e.dept_id = d.id")
        Long total();
        @Select("select e.*,d.name as dept_name from emp e left join dept d on e.dept_id = d.id order by update_time desc limit #{beginPage},#{pageSize}")
        List<Emp> list(Integer beginPage, Integer pageSize);*/
    //使用PageHelper分页

    //    List<Emp> list(String name, Integer gender, LocalDate begin, LocalDate end);
    List<Emp> list(EmpQueryParam empQueryParam);
    @Insert("insert into emp(username,password,name,gender,phone,job,salary,image,entry_date,dept_id,create_time,update_time) values(#{username},#{password},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void addEmp(Emp emp);
    @Select("select * from emp where job=1")
    List<Emp> findAll();

    void deleteByIds(List<Integer> ids);

    Emp findById(Integer id);

    void update(Emp emp);

    List<Map<String, Object>> countEmp();


    List<Map> countEmpGender();

    Emp selectByUsernameAndPassword(Emp emp);

    /**
     *  查询所有员工头像并去重
     * @return
     */
    @Select("select distinct image from emp where image is not null and image != ''")
     List<String> listFiles();
}
